package com.hb.bussiness.service.impl;

import com.hb.bussiness.dto.SimpleEmailEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;


/**
 * @Author jh
 * @Description
 * @Date created in 13:41 2021/12/6
 */
@Service
public class MailServiceImpl {

    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    private String from;

    public void sendSimpleMail(SimpleEmailEntity simpleEmailEntity) {
            SimpleMailMessage message = new SimpleMailMessage();
            message.setFrom(from);
            message.setSubject(simpleEmailEntity.getSubject());
            message.setText(simpleEmailEntity.getContent());
            message.setTo(simpleEmailEntity.getTos());
            mailSender.send(message);
        }



}
